import { lazy } from "react";
import {
  Route,
  BrowserRouter as Router,
  Switch,
  useRouteMatch,
} from "react-router-dom";

const Home = lazy(() => import("views/home/home"));
const Page1 = lazy(() => import("views/page1/page1"));
const Page2 = lazy(() => import("views/page2/page2"));

export default function MainRoute() {
  let { path } = useRouteMatch();
  return (
    <Router>
      <Switch>
        <Route path={`${path}/home`} component={Home}></Route>
        <Route path={`${path}/page1`} component={Page1}></Route>
        <Route path={`${path}/page2`} component={Page2}></Route>
      </Switch>
    </Router>
  );
}
